<template>
  <div>
    <el-dialog :title="FujianFilename" width="98%" top="20px" :visible.sync="showPDFVisibleFujian">
      <Pdfviewer :src="pdfviewersrcFujian" @pdfcloseevent="showPDFVisibleFujian = false"></Pdfviewer>
    </el-dialog>
      <div v-if="fujiandata && fujiandata.length > 0">
      <h1>民主生活会附件</h1>
      <el-table :data="fujiandata" highlight-current-row v-loading="listLoading" style="width: 100%;">
        <el-table-column type="index" label="序号" width="70">
        </el-table-column>
        <el-table-column prop="Stage" label="所属阶段" width="300">
        </el-table-column>
        <el-table-column prop="FileName" label="附件名称">
        </el-table-column>
        <el-table-column prop="Remark" label="备注" width="200">
        </el-table-column>
        <el-table-column label="操作" width="250">
          <template slot-scope="scope">
            <el-button size="small" @click="showfile(scope.row.FileName,scope.row.FilePathName,scope.row.UnitsshId)">查看详情</el-button>
          </template>
        </el-table-column>
      </el-table>
      </div>
      <div v-else style="padding:20px; font-size:14px;color:#999;text-align:center">暂无数据</div>
      <el-dialog :title="FileName" width="98%" top="20px" :visible.sync="showPDFVisible">
        <Pdfviewer :src="PDFsrc" @pdfcloseevent="showPDFVisible = false"></Pdfviewer>
      </el-dialog>
  </div>
</template>
<script>
import Pdfviewer from '@/components/Pdfviewer.vue'
export default {
  components: {
    Pdfviewer
  },
  props: {
    timestamp: ''
  },
  data () {
    return {
      PDFsrc: '',
      pdfpage: 1,
      fujiandata: [],
      listLoading: false,
      showPDFVisible: false,
      FileName: '',
      FujianFilename: '',
      pdfviewersrcFujian: '',
      showPDFVisibleFujian: false
    }
  },
  watch: {
    timestamp (val) {
      this.loaddata()
    }
    // $refs.tree2.getCurrentNode()
  },
  methods: {
    showfile (filename, filepathname, UnitsshId) {
      this.pdfpage = 1
      console.log('pdfpage' + this.pdfpage)
      this.showPDFVisibleFujian = true
      this.FujianFilename = filename
      this.pdfviewersrcFujian = this.$http.defaults.baseURL + 'shenghuohui/getfujian/' + UnitsshId + '?filepathname=' + filepathname + '&t=' + new Date()
    },
    showpdf: function (id, filename) {
      this.FileName = filename
      this.pdfpage = 1
      console.log('pdfpage' + this.pdfpage)
      this.showPDFVisible = true
      this.PDFsrc = this.$http.defaults.baseURL + 'shenghuohui/getfujian/' + id + '?t=' + new Date()
      console.log('url:' + this.PDFsrc)
    },
    loaddata: function () {
      let _this = this
      _this.listLoading = true
      let para = {
        id: this.$route.params.id
      }
      // var personParams = { Page: 0, Pagenum: 20, Personname: '', Unitkey: '', Sortkey: '', Isace: true, timestamp: new Date().getTime() }
      this.$http
        .post(`/shenghuohui/unitfujian`, para)
        .then(function (response) {
          _this.listLoading = false
          if (response.data.IsSuccess === true) {
            console.log('获取成功')
            _this.fujiandata = response.data.Result
          } else {
            console.log('获取数据失败:' + response.data.Msg)
            _this.$message({
              message: '获取数据失败:' + response.data.Msg,
              type: 'error'
            })
          }
        })
        .catch(function (error) {
          console.log(error)
          _this.$message({
            message: '网络获取失败:' + error,
            type: 'error'
          })
          _this.listLoading = false
        })
    }
  }
}
</script>
<style scoped>
.el-form-item{
  margin:0;
}
</style>
